package kernel.stl;

/**
 *
 * @author George
 */
public class PointXYZ {
    
    private double x;
    private double y;
    private double z;
    
    public PointXYZ(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public boolean equals(PointXYZ otherVertex, double tolerance) {
        if (this.distanceTo(otherVertex) > tolerance)
            return false;
        else
            return true;
    }
    
    public double distanceTo(PointXYZ otherPoint) {        
        double deltaX = Math.abs(this.getX() - otherPoint.getX());
        double deltaY = Math.abs(this.getY() - otherPoint.getY());
        double deltaZ = Math.abs(this.getZ() - otherPoint.getZ());
        
        return (double) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);        
    }
    
    public PointXY toPointXY() {
        return new PointXY(this.getX(), this.getY());
    }
    
    public String asString() {
        return "(" + x + ", " + y + ", " + z + ")";
    }
    
    public void exchangeXYAxis() {
        double temp = this.x;
        this.x = this.y;
        this.y = temp;
    }
    
    public void exchangeXZAxis() {
        double temp = this.x;
        this.x = this.z;
        this.z = temp;
    }
    
    public void exchangeYZAxis() {
        double temp = this.y;
        this.y = this.z;
        this.z = temp;    
    }    
    
    public void moveX(double offset) {
        this.x = this.x + offset;
    }
    
    public void moveY(double offset) {
        this.y = this.y + offset;
    }
    
    public void moveZ(double offset) {
        this.z = this.z + offset; 
    }
    
    public double getX() {
        return this.x;        
    }
    
    public double getY() {
        return this.y;
    }
    
    public double getZ() {
        return this.z;
    }
    
    public Vector toVector() {
        Vector v = new Vector(getX(), getY(), getZ()); 
        return v;
    }

}
